package xyz.o0o0o.demo.luajavaDemo;

import java.io.FileNotFoundException;

import org.luaj.vm2.Globals;
import org.luaj.vm2.LuaValue;
import org.luaj.vm2.Varargs;
import org.luaj.vm2.lib.PackageLib;
import org.luaj.vm2.lib.jse.CoerceJavaToLua;
import org.luaj.vm2.lib.jse.JsePlatform;

/**
 * Hello world!
 *
 */
public class App2 {

	static String luaPath1 = "/Users/apple/Documents/helloWorld.lua";
	static String luaPath2 = "/Users/apple/Documents/play.lua";

	public static void main(String[] args) throws FileNotFoundException {
		testPlay();
	}

	public static void testPlay() {
		Globals globals = JsePlatform.standardGlobals();
		LuaValue chunk = globals.loadfile("play.lua");
		chunk.call();

		LuaValue[] values = new LuaValue[3];
		values[0] = CoerceJavaToLua.coerce("2");
		values[1] = CoerceJavaToLua.coerce("1");
		values[2] = CoerceJavaToLua.coerce("01020304050699");

		Varargs result = globals.get("play_check").invoke(values);
		System.out.println(result.arg1());
	}

}
